home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / initscripts.postinst < prev    next >
Encoding:
Text File  |  2007-04-10  |  7.1 KB  |  319 lines

  1. #! /bin/sh
  2. #
  3. # initscripts postinst
  4. #
  5.  
  6. set -e
  7.  
  8. case "$1" in
  9.   configure)
  10.     PREV_VER=$2
  11.     ;;
  12.   abort-upgrade|abort-remove|abort-deconfigure)
  13.     exit 0
  14.     ;;
  15. esac
  16.  
  17. umask 022
  18.  
  19. #
  20. # Function like update-rc.d but simpler & faster.
  21. # Usage: updatercd basename start|stop NN runlevel .
  22. #
  23. # Heuristic: use the real update-rc.d if file-rc is detected,
  24. # or if the /etc/rc2.d directory is not present.
  25. #
  26. updatercd() {
  27.  
  28.     [ -f /etc/init.d/$1 ] || return 0
  29.  
  30.     if \
  31.         [ -d /usr/share/file-rc/. ] \
  32.         || [ -d /usr/lib/file-rc/. ] \
  33.         || [ ! -d /etc/rc2.d/. ]
  34.     then
  35.         # Funniness on next line is because we are running with set -e
  36.         update-rc.d "$@" >/dev/null && return 0 || return $?
  37.     fi
  38.  
  39.     base=$1
  40.     shift
  41.  
  42.     tmp="$(echo /etc/rc?.d/[SK]??$base)"
  43.     case "$tmp" in
  44.         "/etc/rc?.d/[SK]??$base") : ;;
  45.         *) return ;;
  46.     esac
  47.  
  48.     while [ "$1" != "" ]
  49.     do
  50.         if [ "$1" = stop ]
  51.         then
  52.             tlet=K
  53.         else
  54.             tlet=S
  55.         fi
  56.         case "$2" in
  57.             ?) lev=0$2 ;;
  58.             *) lev=$2 ;;
  59.         esac
  60.         shift 2
  61.         while [ "$1" != "." ]
  62.         do
  63.             cd /etc/rc$1.d
  64.             ln -sf ../init.d/$base $tlet$lev$base
  65.             shift
  66.         done
  67.         shift
  68.     done
  69. }
  70.  
  71. #
  72. # Initialize rcS default file.
  73. #
  74. if [ ! -f /etc/default/rcS ]
  75. then
  76.     cp -p /usr/share/initscripts/default.rcS /etc/default/rcS
  77. fi
  78.  
  79. #
  80. # In 2.86.ds1-7 the "single" script was moved.
  81. # We have to remove the old links _before_ we install new ones.
  82. #
  83. if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-7"
  84. then
  85.     update-rc.d -f single remove >/dev/null 2>&1 || :
  86. fi
  87.  
  88. #
  89. # Okay, we could do this with update-rc.d, but that would probably
  90. # be pretty slow. This way we win some speed.
  91. # DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES.
  92. #
  93. # Links in runlevel S
  94. #
  95. updatercd mountkernfs.sh         start 1 S .
  96. updatercd hostname.sh            start 2 S .
  97. updatercd mountdevsubfs.sh       start 11 S .
  98. #updatercd modutils               start 15 S .
  99. #updatercd bootlogd               start 18 S .
  100. updatercd checkroot.sh           start 20 S .
  101. updatercd mtab.sh                start 22 S .
  102. updatercd checkfs.sh             start 30 S .
  103. updatercd mountall.sh            start 35 S .
  104. updatercd mountall-bootclean.sh  start 36 S .
  105. updatercd waitnfs.sh             start 45 S .
  106. updatercd mountnfs-bootclean.sh  start 46 S .
  107. updatercd bootmisc.sh            start 80 S .
  108. updatercd urandom                start 85 S . start 30 0 6 .
  109. #
  110. # Links in runlevels other than S
  111. #
  112. updatercd sendsigs               start 20 0 6 .
  113. updatercd umountnfs.sh           start 31 0 6 .
  114. updatercd umountfs               start 40 0 6 .
  115. updatercd umountroot             start 60 0 6 .
  116. updatercd halt                   start 90 0 .
  117. updatercd reboot                 start 90 6 .
  118. updatercd killprocs              start 30 1 .
  119. updatercd single                 start 90 1 .
  120. updatercd rc.local               start 99 2 3 4 5 .
  121. updatercd rmnologin              start 99 2 3 4 5 .
  122. #updatercd stop-bootlogd-single   start 99 S .
  123. #updatercd stop-bootlogd          start 99 2 3 4 5 .
  124.  
  125. #
  126. # Remove scripts that were left behind by older versions
  127. #
  128. for F in mountkernfs devpts.sh mountvirtfs mountdevsubfs mtab
  129. do
  130.     rm -f /etc/init.d/$F
  131.     update-rc.d $F remove >/dev/null 2>&1 || :
  132. done
  133.  
  134. rm -f /etc/init.d/bootclean.sh
  135.  
  136. #
  137. # Create /var/run and /var/lock
  138. #
  139. if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu12"
  140. then
  141.     # We need to quickly bind / to another location so we can make them
  142.     # just in case /var is a mountpoint or a symlink to one.
  143.     mkdir /.root
  144.     mount -n --bind / /.root
  145.  
  146.     mkdir -p /.root/var/run /.root/var/lock
  147.  
  148.     umount /.root
  149.     rmdir /.root
  150. fi
  151.  
  152. #
  153. # Mount /var/run and /var/lock
  154. #
  155. if [ "$PREV_VER" ] && dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu12"
  156. then
  157.     # Make /var/run a tmpfs, and move everything onto it.  This will
  158.     # probably break a few running things.  If already a tmpfs, try
  159.     # cleaning up the one underneath
  160.     mkdir /tmp/.var.run
  161.     if mountpoint -q /var/run; then
  162.         mount -n --move /var/run /tmp/.var.run
  163.     else
  164.         mount -n -t tmpfs varrun /tmp/.var.run
  165.         (cd /var/run && find -print0 | cpio -p0dm /tmp/.var.run) 2>/dev/null || true
  166.     fi
  167.     find /var/run ! -type d -exec rm -f -- {} \; || true
  168.     mount -n --move /tmp/.var.run /var/run
  169.     rmdir /tmp/.var.run
  170.  
  171.     # And do the same for /var/lock
  172.     mkdir /tmp/.var.lock
  173.     if mountpoint -q /var/lock; then
  174.         mount -n --move /var/lock /tmp/.var.lock
  175.     else
  176.         mount -n -t tmpfs varlock /tmp/.var.lock
  177.         (cd /var/lock && find -print0 | cpio -p0dm /tmp/.var.lock) 2>/dev/null || true
  178.     fi
  179.     find /var/lock ! -type d -exec rm -f -- {} \; || true
  180.     mount -n --move /tmp/.var.lock /var/lock
  181.     rmdir /tmp/.var.lock
  182.  
  183.     if [ -x /usr/share/update-notifier/notify-reboot-required ]; then
  184.         /usr/share/update-notifier/notify-reboot-required
  185.     fi
  186. fi
  187.  
  188. #
  189. # Create initial log files
  190. #
  191. [ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
  192. for F in /var/log/dmesg /var/log/boot /var/log/fsck/checkroot /var/log/fsck/checkfs
  193. do
  194.     if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
  195.     then
  196.         echo "(Nothing has been logged yet.)" >| "$F"
  197.         chown root:adm "$F"
  198.         chmod 640 "$F"
  199.     fi
  200. done
  201.  
  202. #
  203. # Set up nologin symlink so that dynamic-login-disabling will work
  204. # (when DELAYLOGIN is set to "yes")
  205. #
  206. if [ ! -L /etc/nologin ] && [ ! -e /etc/nologin ]
  207. then
  208.     rm -f /var/lib/initscripts/nologin
  209.     ln -s /var/lib/initscripts/nologin /etc/nologin
  210. fi
  211.  
  212. #
  213. # Set up motd stuff, putting variable file in /var/run/
  214. #
  215. if [ ! -f /etc/motd.tail ]
  216. then
  217.     if [ -f /etc/motd ]
  218.     then
  219.         sed 1d /etc/motd > /etc/motd.tail
  220.         [ -s /etc/motd.tail ] || rm -f /etc/motd.tail
  221.     fi
  222. fi
  223. if [ ! -f /var/run/motd ]
  224. then
  225.     if [ -f /etc/motd ]
  226.     then
  227.         cat /etc/motd > /var/run/motd
  228.     else
  229.         :>/var/run/motd
  230.     fi
  231. fi
  232. if [ ! -L /etc/motd ]
  233. then
  234.     [ -f /etc/default/rcS ] && . /etc/default/rcS
  235.     if [ "$EDITMOTD" = no ]
  236.     then
  237.         cat /var/run/motd > /etc/motd.static
  238.         ln -sf motd.static /etc/motd
  239.     else
  240.         ln -sf /var/run/motd /etc/motd
  241.     fi
  242. fi
  243.  
  244. #
  245. # Mount kernel virtual filesystems...not.
  246. # This causes problems in pbuilder.
  247. #
  248. #
  249. #if [ -x /etc/init.d/mountkernfs.sh ]
  250. #then
  251. #    if which invoke-rc.d >/dev/null 2>&1
  252. #    then
  253. #        invoke-rc.d mountkernfs.sh start || :
  254. #    else
  255. #        /etc/init.d/mountkernfs.sh start
  256. #    fi
  257. #fi
  258.  
  259. #
  260. # Create /dev/pts, /dev/shm directories
  261. #
  262. if [ "$(uname -s)" = Linux ]
  263. then
  264.     #
  265.     # Only create /dev/{pts,shm} if /dev is on the
  266.     # root file system. If some package has mounted a
  267.     # seperate /dev (ramfs from udev, devfs) it is
  268.     # responsible for the presence of those subdirs.
  269.     #
  270.     if ! mountpoint -q /dev
  271.     then
  272.         [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts ; }
  273.         [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm ; }
  274.     fi
  275. fi
  276.  
  277. #
  278. # Create /etc/rc.local
  279. #
  280. if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-6ubuntu19"
  281. then
  282.     if [ ! -e /etc/rc.local ]; then
  283.         cat << EOF > /etc/rc.local
  284. #!/bin/sh -e
  285. #
  286. # rc.local
  287. #
  288. # This script is executed at the end of each multiuser runlevel.
  289. # Make sure that the script will "exit 0" on success or any other
  290. # value on error.
  291. #
  292. # In order to enable or disable this script just change the execution
  293. # bits.
  294. #
  295. # By default this script does nothing.
  296.  
  297. exit 0
  298. EOF
  299.         # make sure it's enabled by default.
  300.         chmod 755 /etc/rc.local
  301.     fi
  302. fi
  303.  
  304. #
  305. # Mount virtual filesystems under /dev...not.
  306. # This causes problems in pbuilder.
  307. #
  308. #if [ -x /etc/init.d/mountdevsubfs.sh ]
  309. #then
  310. #    if which invoke-rc.d >/dev/null 2>&1
  311. #    then
  312. #        invoke-rc.d mountdevsubfs.sh start || :
  313. #    else
  314. #        /etc/init.d/mountdevsubfs.sh start
  315. #    fi
  316. #fi
  317.  
  318. :
  319.